package manager;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ManagerStoreServlet extends HttpServlet
{
	public void doGet(HttpServletRequest request, HttpServletResponse response)
	{
		try
		{
			performPreTask(request, response);
		}
		catch(Exception e)
		{
			e.printStackTrace(System.out);
		}
	}
	public void doPost(HttpServletRequest request, HttpServletResponse response )
	{
		try
		{
			performPreTask(request, response);
		}
		catch(Exception e)
		{
			e.printStackTrace(System.out);
		}
	}
	public void performPreTask(HttpServletRequest request, HttpServletResponse response) throws Exception
	{
		String func = request.getParameter("func");
		
		if(func.equals("managerStore_001"))
		{
			request.setAttribute("menuUrl","/manager_common/Menu1.jsp");
			request.setAttribute("menu","menu01");
			(request.getRequestDispatcher("/manager_common/Frame.jsp")).forward(request, response);
			
		}
		else if(func.equals("managerStore_002"))
		{
			request.setAttribute("menuUrl","/manager_common/Menu2.jsp");
			request.setAttribute("menu","menu02");
			(request.getRequestDispatcher("/manager_common/Frame.jsp")).forward(request, response);
		}
		else if(func.equals("managerStore_003"))
		{
			String type = "A";
			if (request.getParameter("type") != null) {
				type = request.getParameter("type");
			}		
			String menuUrl = "/manager_common/Menu3.jsp";
			if (type.equals("B")) {
				menuUrl = "/manager_common/Menu4.jsp";
			}
			request.setAttribute("menuUrl",menuUrl);
			request.setAttribute("menu","menu03");
			request.setAttribute("type",type);
			
			(request.getRequestDispatcher("/manager_common/Frame.jsp")).forward(request, response);
		}
		else if(func.equals("managerStore_004"))
		{
			
			request.setAttribute("menuUrl","/manager_common/Menu5.jsp");
			request.setAttribute("menu","menu05");
			(request.getRequestDispatcher("/manager_common/Frame.jsp")).forward(request, response);
		}
		else if(func.equals("managerStore_005"))
		{
			
			request.setAttribute("menuUrl","/manager_common/Menu6.jsp");
			request.setAttribute("menu","menu06");
			(request.getRequestDispatcher("/manager_common/Frame.jsp")).forward(request, response);
		}
	}
}
